package cn.com.dcsgo.library.client.controller;

import cn.com.dcsgo.library.client.response.ResponseResult;
import cn.com.dcsgo.library.client.service.IUsersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.jdbc.Null;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户相关接口
 *
 * @author Dcsgo
 * @since 2024-09-02
 */
@RestController
@RequestMapping("/users")
@Api(tags = "用户相关接口")
@RequiredArgsConstructor
public class UsersController {
    private final IUsersService usersService;

    @GetMapping("login/{username}/{password}")
    @ApiOperation("登录")
    public ResponseResult<Long> login(@PathVariable String username,
                                      @PathVariable String password) {
        try {
            return ResponseResult.success(usersService.login(username, password));
        } catch (IllegalArgumentException iae) {
            return ResponseResult.fail(iae.getMessage());
        }
    }
}
